<template>
  <div class="album" v-if="albumList">
    <template v-for="item in albumList">
      <div class="contentBox" :key="item.id">
        <div class="imgBox">
          <img :src="item.blurPicUrl" alt />
        </div>
        <div class="text">
          <p>
            {{item.name}}
            <span v-if="item.alias[0]">({{item.alias[0]}})</span>
          </p>
          <span :class="{'singerName':item.artists[0].name=='薛之谦'}">{{item.artists[0].name}}</span>
          <span>{{changeTime(item.publishTime)}}</span>
        </div>
      </div>
    </template>
  </div>
</template>

<script>
import util from "@/assets/js/util.js";
export default {
  components: {},
  props: ["singerName"],
  data() {
    return {
      albumList: ""
    };
  },
  watch: {
    singerName: function() {
      this.$http("/search", {
        params: {
          keywords: this.singerName,
          type: 10
        }
      }).then(res => {
        console.log(res);
        this.albumList = res.data.result.albums;
      });
    }
  },
  computed: {},
  methods: {
    changeTime: util.transformDate3
  },
  created() {
    this.$http("/search", {
      params: {
        keywords: this.singerName,
        type: 10
      }
    }).then(res => {
      console.log(res);
      this.albumList = res.data.result.albums;
    });
  },
  mounted() {
    console.log(this.albumList);
  }
};
</script>
<style lang="scss" scoped>
@import "~@/assets/css/common.scss";
.album {
  padding: vw(10) vw(20);
  .contentBox {
    width: 100%;
    display: flex;
    align-items: center;
    padding: vw(10) 0;
    .imgBox {
      width: vw(50);
      height: vw(50);
      border-radius: vw(5);
      overflow: hidden;
      img {
        width: 100%;
      }
    }
    .text {
      padding-left: vw(10);
      p {
        font-size: vw(16);
        padding-bottom: vw(4);
      }
      span {
        font-size: vw(14);
        color: #777;
      }
      .singerName {
        color: skyblue;
      }
    }
  }
}
</style>